package com.yhhvip.order.dao;

import com.yhhvip.order.entity.Company;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;


@Repository
public interface CompanyDao extends JpaRepository<Company,Integer>,JpaSpecificationExecutor<Company> {

    //添加用户总余额
    @Transactional
    @Modifying
    @Query("update Company company set company.totalAmount=company.totalAmount+?1 where company.companyId=?2 and company.totalAmount=?3")
    Integer updCompanyTotalAmount(BigDecimal totalAmount, Integer userId, BigDecimal nowTotalAmount);
}
